package action;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import logic.AddressLogic;
import logic.NewLogic;
import model.Address;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import action.form.AddressForm;

import dao.AddressDAO;
import dao.DAOHelper;
import dao.NewDAO;
import dao.sqlmap.AddressSQLMapDao;
import dao.sqlmap.NewSQLMapDao;



public class NewAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
	AddressForm newForm = (AddressForm)form;
	Address add=new Address();	
	add.setName(newForm.getName());
	add.setZip(newForm.getZip());
	add.setAddress1(newForm.getAddress1());
	add.setAddress2(newForm.getAddress2());
	add.setTel(newForm.getTel());
	add.setFax(newForm.getFax());
	add.setEmail(newForm.getEmail());
	request.getSession().setAttribute("address",add);
	NewLogic  logic = new NewLogic();
	logic.insertAddress(add);
    
	AddressLogic  logic2 = new AddressLogic();
	logic2.getAllAddresses(request);
    
		 return mapping.findForward("success");

	}
}
